#! /usr/bin/python
# coding: utf-8

from Tkinter import *

root = Tk()

def printEvent(event):
    print '<instance>', event.keycode

def printToplevel(event):
    print '<toplevel>', event.keycode

def printClass(event):
    print '<bind_class>', event.keycode

def printAppAll(event):
    print '<bind_all>', event.keycode

bt1 = Button(root, text='instance event')
bt1.bind('<Return>', printEvent)

bt1.winfo_toplevel().bind('<Return>', printToplevel)

root.bind_class('Button', '<Return>', printClass)

bt1.bind_all('<Return>', printAppAll)

bt1.focus_set()
bt1.grid()

root.mainloop()
